package Messages;

import java.io.IOException;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the edit vase details in DB
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageMakeVaseUpdate {
	private ConnectionToClient client ;
	private String[] str;
/**
 * Constructor of this class 
 * @param str
 * @param client
 */
	public MessageMakeVaseUpdate(String[] str, ConnectionToClient client){
		
		this.client= client ;
		this.str= str; 	
	
	}
	/**
	 * This method update the vase details in the DB 
	 * @throws SQLException
	 * @throws IOException
	 */
public void MakeVaseUpdate() throws SQLException, IOException{
		
		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("Update db.vases SET height=?,inventorystock=?,rentstock=? WHERE name=? and color=?");
		ps.setString(1, str[3]);
		ps.setString(2, str[4]);
		ps.setString(3, str[5]);
		ps.setString(4, str[1]);
		ps.setString(5, str[2]);
		ps.executeUpdate();
		client.sendToClient("MakeVaseUpdate");
		ps.close();
		
		}

}
